#e
#Title[zNuǂǂ^[v]
#Text[gE}̈B]
#ScriptVersion[2]
script_enemy_main
{
	let scroll=0;
	let flag=0;
	let cx=GetCenterX();//STGV[̒SxW擾
	let cy=GetCenterY();//STGV[̒SyW擾
	let boss=GetCurrentScriptDirectory~"img\boss7-2.png";
	let eye=GetCurrentScriptDirectory~"img\bg7-1.png";
	let asa=GetCurrentScriptDirectory~"img\bg7-2.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(600);
		SetDamageRate(10,0);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(80);
		SetInvincibility(60);
		LoadGraphic(boss);
		LoadGraphic(eye);
		LoadGraphic(asa);
		shottask;
		shottask2;
		drawtask;
		bombtask;
		CutIn(YOUMU,"zNuǂǂ^[v",0,0,0,0,0);//XyJ[h\
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{
		loop(16)
		{
			CreateItem(ITEM_SCORE,GetX+rand(-30,30),GetY+rand(-30,30));
		}
		CreateItem(ITEM_BOMB,GetX,GetY);
		DeleteGraphic(boss);
		DeleteGraphic(eye);
		DeleteGraphic(asa);
	}
	@DrawLoop
	{
		SetTexture(boss);	
		if(flag==1)
		{
			SetGraphicRect(52,0,81,63);
		}
		else if(flag==2)
		{
			SetGraphicRect(24,0,52,63);
		}
		else
		{
			SetGraphicRect(0,0,24,63);
		}
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetX,GetY);
	}
	@BackGround
	{
		SetColor(128,128,128);
		SetTexture(eye);	
		SetGraphicRect(0,0,384,448);
		SetAlpha(255);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		DrawGraphic(cx,cy);
		SetColor(255,255,255);
		SetTexture(asa);	
		SetGraphicRect(0,0,888,189*5);
		SetAlpha(64);
		SetGraphicScale(0.5,0.75);
		SetGraphicAngle(0,0,0);
		DrawGraphic(cx+scroll,cy);
		DrawGraphic(cx+scroll-444,cy);
		if(scroll>444)
		{
			scroll=0;
		}
	}
	task shottask
	{
		let angle=0;
		wait(120);
		loop
		{
			CreateShot01(GetX,GetY,1,angle*1.3,12,3);
			CreateShot01(GetX,GetY,1,-angle*2,12,3);
			angle+=7;
			wait(2)
		}
	}
	task shottask2
	{
		let y=GetClipMaxY;
		wait(120);
		loop(120)
		{
			SetShotColor(0,255,0);
			loop(5)
			{
				shot(y);
			}
			SetShotColor(255,255,255);
			yield;
			y-=0.4;
		}
		loop
		{
			SetShotColor(0,255,0);
			loop(5)
			{
				shot(y);
			}
			SetShotColor(255,255,255);
			yield;
			if(y>cy)
			{
				y-=0.15;
			}
		}
		
	}
	task drawtask
	{
		let x=0;
		loop
		{	
			if(GetX>x+0.5)
			{
				flag=1;
			}
			else if(GetX<x-0.5)
			{
				flag=2;
			}
			else
			{
				flag=0;
			}
			x=GetX;
			scroll++;
			yield;
		}
	}
	task bombtask
	{
		loop
		{
			if(OnBomb)
			{
				SetAlpha(64);
				SetDamageRate(0,0);
			}
			else
			{
				SetAlpha(255);
				SetDamageRate(10,0);
				SetCollisionA(GetX(),GetY(),24);
				SetCollisionB(GetX(),GetY(),24);
			}
			yield;
		}
	}
	function shot(let y)
	{
		let s=0;
		CreateShotA(s,rand(GetClipMinX,GetClipMaxX),y,3);
		SetShotDataA(s,0,1,90,0,0,2,157);
		FireShot(s);
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}